home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 487 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. From: Bjorn Fahller <ebcbear@ebc.ericsson.se>
  2. Message-ID: <312495AD.757A@ebc.ericsson.se>
  3. X-Original-Date: Fri, 16 Feb 1996 15:33:17 +0100
  4. Path: in2.uu.net!bounce-back
  5. Date: 19 Feb 96 04:30:21 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Return-Path: <daemon@meeker.UCAR.EDU>
  9. Organization: Ericsson Business Networks AB
  10. X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.05 9000/735)
  11. Subject: Re: Q: Generic Callbacks -- "Object->*func(...)"
  12. References: <4fti32$p3p@bcarh8ab.bnr.ca> <4g0csh$dq5@news.bridge.net>
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMSf9FeEDnX0m9pzZAQEhpgGAltpe27z7iGrILhZaGbDdC2KS0nvDJfrN
  15.     DP4ejUeE5uCJJQY4MZ6Do+IX6c3A6Q/G
  16.     =s+0z
  17.  
  18. David Byrden <100101.2547@compuserve.com> wrote:
  19. > >> I'd like to be able to call "DoIt" with any type of object and a
  20. > >> pointer to any of that object's member functions that match the
  21. > >> 'parmlist'
  22. >  In the C++ Report, February 1995, Richard Hickey suggested a library of
  23. > universal callback functors which would encapsulate both an object
  24. > reference and a pointer to a member function of that object.
  25. >  The caller, and the provider of the callback, would not have to share
  26. > any type information other than the callback library itself.
  27.  
  28. Unfortunately the implementation is all but clean, and depends
  29. heavily on the compiler used. Internally, everything is
  30. casted to void*. When I tried the implementation on Sun SparcWorks,
  31. it failed, since pointer to member functions cannot be casted
  32. to void* without severe loss of precision (they're twise
  33. as long as void*.)
  34.  
  35. The ideas are still usable, though. Those who are interested
  36. can e-mail me for a simple example (not quite as slick as the
  37. original, but not compiler dependant since it doesn't use
  38. ugly casts.)
  39.    _
  40. /Bjorn.
  41. --
  42. Bjorn Fahller                  Tel: +46 8 4220898 / 
  43. NA/EBC/F/SNM/T                 -------------------            ^
  44. Ericsson Business Networks AB /                               |
  45. S-131 89 Stockholm/SWEDEN    / Clever quote goes right here --+
  46. ---
  47. [ To submit articles: Try just posting with your news-reader.
  48.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  49.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  50.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  51.   Comments? mailto:std-c++-request@ncar.ucar.edu
  52. ]
  53.